<script lang="ts">
import {reactive, ref, toRefs} from "vue";

export default {
  name: 'Person',
  setup() {
    let person = reactive({
      name: '张飒飒',
      age: 18,
      phone: '0123456789',
    });
    let num = ref(0);

    // 方法
    function showPhone() {
      alert("显示电话信息：" + person.phone);
    }

    return {
      ...toRefs(person),
      showPhone,
      num,
    };
  }
}
</script>

<template>
  <div class="person">
    <h1>人员信息：</h1>
    <span>姓名：{{ name }}</span><br>
    <span>年龄：{{ age }}</span><br>
    <span>num的值：{{ num }}</span><br>
    <button @click="showPhone()">显示电话</button>
    <button @click="name += '====>'">名字变幻</button>
    <button @click="age += 1">年龄变幻</button>
    <button @click="num+=1">num+1</button>
  </div>
</template>

<style scoped>
.person {
  background-color: #dab649;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}

button {
  margin: 0 10px;
}
</style>